package com.shg.admin.controller;

import com.shg.admin.bean.City;
import com.shg.admin.service.CityService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping(value = "/city")
public class CityController {
    
    private final CityService cityService;

    public CityController(CityService cityService) {
        this.cityService = cityService;
    }

    @GetMapping
    @ResponseBody
    public City getCityById(@RequestParam("id") Long id){
        return cityService.selectCityById(id);
    }
    
    @GetMapping(value = "/list")
    @ResponseBody
    public List<City> getListCity(){
        return cityService.selectListCity();
    }
}
